/*
package com.zlx.mall.basic.quartz;


import com.zlx.mall.base.entity.ScQuartzJob;
import com.zlx.mall.basic.util.json.JacksonUtil;
import lombok.extern.slf4j.Slf4j;
import org.quartz.*;
import org.springframework.util.ClassUtils;

import java.util.List;
import java.util.stream.Collectors;

*/
/**
 * @author qingke
 **//*

@Slf4j
public class QuartzUtil {

    */
/**
     * Build Job Key
     *
     * @param job ScQuartzJob
     * @return JobKey
     *//*

    public static JobKey buildJobKey(ScQuartzJob job) {
        return new JobKey(job.getJobName(), job.getJobGroup());
    }

    */
/**
     * Build Trigger Key
     *
     * @param job ScQuartzJob
     * @return TriggerKey
     *//*

    public static TriggerKey buildTriggerKey(ScQuartzJob job) {
        return new TriggerKey(job.getJobName(), job.getJobGroup());
    }

    */
/**
     * Build Job Detail
     *
     * @param job ScQuartzJob
     * @return JobDetail
     * @throws SchedulerException if resolveClassName error
     *//*

    @SuppressWarnings("unchecked")
    public static JobDetail buildJobDetail(ScQuartzJob job)
            throws SchedulerException {
        try {
            // throw IllegalArgumentException
            Class<? extends Job> jobClass = (Class<? extends Job>)
                    ClassUtils.resolveClassName(job.getJobClassName(), ClassUtils.getDefaultClassLoader());

            return JobBuilder
                    .newJob()
                    .withIdentity(buildJobKey(job))
                    .withDescription(job.getJobDescription())
                    .ofType(jobClass)
                    .setJobData(new JobDataMap(JacksonUtil.toMapObject(job.getJobData())))
                    .build();

        } catch (IllegalArgumentException e) {
            throw new SchedulerException("ClassUtils resolve class name failed.", e);
        }
    }

    */
/**
     * Create Job
     *
     * @param scheduler Scheduler
     * @param job       JobBean
     *//*

    public static void createScheduleJob(Scheduler scheduler, ScQuartzJob job)
            throws SchedulerException {
        try {
            JobDetail jobDetail = buildJobDetail(job);

            CronTrigger cronTrigger = TriggerBuilder
                    .newTrigger()
                    .withIdentity(buildTriggerKey(job))
                    .withSchedule(CronScheduleBuilder.cronSchedule(job.getCronExpression()))
                    .forJob(jobDetail.getKey())
                    .build();

            // throw SchedulerException
            scheduler.scheduleJob(jobDetail, cronTrigger);

        } catch (SchedulerException e) {
            throw e;
        } catch (Exception other) {
            throw new SchedulerException(other);
        }
    }

    */
/**
     * Pause Job
     *
     * @param scheduler scheduler
     * @param job       JobBean
     *//*

    public static void pauseScheduleJob(Scheduler scheduler, ScQuartzJob job)
            throws SchedulerException {
        scheduler.pauseJob(buildJobKey(job));
    }

    */
/**
     * Resume Job
     *
     * @param scheduler scheduler
     * @param job       JobBean
     *//*

    public static void resumeScheduleJob(Scheduler scheduler, ScQuartzJob job)
            throws SchedulerException {
        scheduler.resumeJob(buildJobKey(job));
    }

    */
/**
     * Run Once
     *
     * @param scheduler scheduler
     * @param job       JobBean
     *//*

    public static void runOnce(Scheduler scheduler, ScQuartzJob job)
            throws SchedulerException {
        scheduler.addJob(buildJobDetail(job), true);
        scheduler.triggerJob(buildJobKey(job));
    }

    */
/**
     * Delete Job
     *
     * @param scheduler scheduler
     * @param job       JobBean
     *//*

    public static boolean deleteScheduleJob(Scheduler scheduler, ScQuartzJob job)
            throws SchedulerException {
        return scheduler.deleteJob(buildJobKey(job));
    }

    */
/**
     * Batch Delete Jobs
     *
     * @param scheduler scheduler
     * @param jobs      jobs
     * @return if all deleted
     *//*

    public static boolean deleteScheduleJobs(Scheduler scheduler, List<ScQuartzJob> jobs)
            throws SchedulerException {
        List<JobKey> keys = jobs.stream()
                .map(QuartzUtil::buildJobKey)
                .collect(Collectors.toList());

        // true if all the Jobs were found and deleted,
        // false if one or more were not deleted.
        return scheduler.deleteJobs(keys);
    }

    */
/**
     * Update Job
     *
     * @param scheduler scheduler
     * @param job       JobBean
     *//*

    public static void updateScheduleJob(Scheduler scheduler, ScQuartzJob job)
            throws SchedulerException {
        // ignored job was not found
        deleteScheduleJob(scheduler, job);
        createScheduleJob(scheduler, job);
    }

}
*/
